<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
--><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
<meta name="generator" content="joDoc">
<title>Apache Cordova API Documentation</title>
<link rel="stylesheet" type="text/css" href="index.css">
<link rel="stylesheet" type="text/css" href="mobile.css" media="only screen and (max-device-width: 1024px)">
<link rel="stylesheet" type="text/css" href="prettify/prettify.css">
</head>
<body>
        <div id="header">
            <h1><a href="index.html">Apache <strong>Cordova</strong> Documentation</a></h1>
            <small>
                <select><optgroup label="English" value="en">
<option value="edge">edge</option>
<option value="2.2.0rc2">2.2.0rc2</option>
<option value="2.2.0rc1">2.2.0rc1</option>
<option selected value="2.2.0">2.2.0</option>
<option value="2.1.0rc2">2.1.0rc2</option>
<option value="2.1.0rc1">2.1.0rc1</option>
<option value="2.1.0">2.1.0</option>
<option value="2.0.0rc1">2.0.0rc1</option>
<option value="2.0.0">2.0.0</option>
<option value="1.9.0rc1">1.9.0rc1</option>
<option value="1.9.0">1.9.0</option>
<option value="1.8.1">1.8.1</option>
<option value="1.8.0rc1">1.8.0rc1</option>
<option value="1.8.0">1.8.0</option>
<option value="1.7.0rc1">1.7.0rc1</option>
<option value="1.7.0">1.7.0</option>
<option value="1.6.1">1.6.1</option>
<option value="1.6.0rc1">1.6.0rc1</option>
<option value="1.6.0">1.6.0</option>
<option value="1.5.0rc1">1.5.0rc1</option>
<option value="1.5.0">1.5.0</option>
<option value="1.4.1">1.4.1</option>
<option value="1.4.0rc1">1.4.0rc1</option>
<option value="1.4.0">1.4.0</option>
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
<option value="1.0.0rc3">1.0.0rc3</option>
<option value="1.0.0rc2">1.0.0rc2</option>
<option value="1.0.0rc1">1.0.0rc1</option>
<option value="1.0.0">1.0.0</option>
<option value="0.9.6">0.9.6</option>
<option value="0.9.5.1">0.9.5.1</option>
<option value="0.9.5">0.9.5</option>
<option value="0.9.4">0.9.4</option>
<option value="0.9.3">0.9.3</option>
<option value="0.9.2">0.9.2</option>
</optgroup>
<optgroup label="Español" value="es"><option value="1.0.0">1.0.0</option></optgroup>
<optgroup label="Français" value="fr">
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
</optgroup>
<optgroup label="Japanese" value="jp">
<option value="2.0.0">2.0.0</option>
<option value="1.9.0">1.9.0</option>
<option value="1.8.1">1.8.1</option>
<option value="1.7.0">1.7.0</option>
<option value="0.9.5">0.9.5</option>
</optgroup>
<optgroup label="Korean" value="kr"><option value="2.0.0">2.0.0</option></optgroup></select></small>
        </div>
        <div id="subheader">
            <h1>Storage</h1>
            <small><select><option value="Storage">Storage</option>
<option value="Storage_methods">      - Methods</option>
<option value="Storage_arguments">      - Arguments</option>
<option value="Storage_objects">      - Objects</option>
<option value="Storage_permissions">      - Permissions</option>
<option value="openDatabase">openDatabase</option>
<option value="openDatabase_description">      - Description</option>
<option value="openDatabase_supported_platforms">      - Supported Platforms</option>
<option value="openDatabase_quick_example">      - Quick Example</option>
<option value="openDatabase_full_example">      - Full Example</option>
<option value="database_name">database_name</option>
<option value="database_version">database_version</option>
<option value="database_displayname">database_displayname</option>
<option value="database_size">database_size</option>
<option value="Database">Database</option>
<option value="Database_methods">      - Methods</option>
<option value="Database_details">      - Details</option>
<option value="Database_supported_platforms">      - Supported Platforms</option>
<option value="Database_transaction_quick_example">      - Transaction Quick Example</option>
<option value="Database_change_version_quick_example">      - Change Version Quick Example</option>
<option value="Database_full_example">      - Full Example</option>
<option value="SQLTransaction">SQLTransaction</option>
<option value="SQLTransaction_methods">      - Methods</option>
<option value="SQLTransaction_details">      - Details</option>
<option value="SQLTransaction_supported_platforms">      - Supported Platforms</option>
<option value="SQLTransaction_execute_sql_quick_example">      - Execute SQL Quick Example</option>
<option value="SQLTransaction_full_example">      - Full Example</option>
<option value="SQLResultSet">SQLResultSet</option>
<option value="SQLResultSet_properties">      - Properties</option>
<option value="SQLResultSet_details">      - Details</option>
<option value="SQLResultSet_supported_platforms">      - Supported Platforms</option>
<option value="SQLResultSet_execute_sql_quick_example">      - Execute SQL Quick Example</option>
<option value="SQLResultSet_full_example">      - Full Example</option>
<option value="SQLResultSetList">SQLResultSetList</option>
<option value="SQLResultSetList_properties">      - Properties</option>
<option value="SQLResultSetList_methods">      - Methods</option>
<option value="SQLResultSetList_details">      - Details</option>
<option value="SQLResultSetList_supported_platforms">      - Supported Platforms</option>
<option value="SQLResultSetList_execute_sql_quick_example">      - Execute SQL Quick Example</option>
<option value="SQLResultSetList_full_example">      - Full Example</option>
<option value="SQLError">SQLError</option>
<option value="SQLError_properties">      - Properties</option>
<option value="SQLError_constants">      - Constants</option>
<option value="SQLError_description">      - Description</option>
<option value="localStorage">localStorage</option>
<option value="localStorage_methods">      - Methods</option>
<option value="localStorage_details">      - Details</option>
<option value="localStorage_supported_platforms">      - Supported Platforms</option>
<option value="localStorage_key_quick_example">      - Key Quick Example</option>
<option value="localStorage_set_item_quick_example">      - Set Item Quick Example</option>
<option value="localStorage_get_item_quick_example">      - Get Item Quick Example</option>
<option value="localStorage_remove_item_quick_example">      - Remove Item Quick Example</option>
<option value="localStorage_clear_quick_example">      - Clear Quick Example</option>
<option value="localStorage_full_example">      - Full Example</option>
<option value="localStorage_windows_phone_7_quirks">      - Windows Phone 7 Quirks</option></select></small>
        </div>

        <div id="sidebar">
            <div class="vertical_divider"></div>
        <h1>API Reference</h1>
<ul>
<li><a href="cordova_accelerometer_accelerometer.md.html#Accelerometer">Accelerometer</a></li>
<li><a href="cordova_camera_camera.md.html#Camera">Camera</a></li>
<li><a href="cordova_media_capture_capture.md.html#Capture">Capture</a></li>
<li><a href="cordova_compass_compass.md.html#Compass">Compass</a></li>
<li><a href="cordova_connection_connection.md.html#Connection">Connection</a></li>
<li><a href="cordova_contacts_contacts.md.html#Contacts">Contacts</a></li>
<li><a href="cordova_device_device.md.html#Device">Device</a></li>
<li><a href="cordova_events_events.md.html#Events">Events</a></li>
<li><a href="cordova_file_file.md.html#File">File</a></li>
<li><a href="cordova_geolocation_geolocation.md.html#Geolocation">Geolocation</a></li>
<li><a href="cordova_globalization_globalization.md.html#Globalization">Globalization</a></li>
<li><a href="cordova_media_media.md.html#Media">Media</a></li>
<li><a href="cordova_notification_notification.md.html#Notification">Notification</a></li>
<li><a href="cordova_splashscreen_splashscreen.md.html#Splashscreen">Splashscreen</a></li>
<li><a href="cordova_storage_storage.md.html#Storage">Storage</a></li>
</ul>
<h1>Guides</h1>
<ul>
<li><a href="guide_getting-started_index.md.html#Getting%20Started%20Guides">Getting Started Guides</a></li>
<li><a href="guide_command-line_index.md.html#Command-Line%20Usage">Command-Line Usage</a></li>
<li><a href="guide_upgrading_index.md.html#Upgrading%20Guides">Upgrading Guides</a></li>
<li><a href="guide_project-settings_index.md.html#Project%20Settings">Project Settings</a></li>
<li><a href="guide_plugin-development_index.md.html#Plugin%20Development%20Guide">Plugin Development Guide</a></li>
<li><a href="guide_whitelist_index.md.html#Domain%20Whitelist%20Guide">Domain Whitelist Guide</a></li>
<li><a href="guide_cordova-webview_index.md.html#Embedding%20WebView">Embedding WebView</a></li>
<li><a href="_index.html">Keyword Index</a></li>
</ul>
</div>

        <div id="scrollable">
            <div id="content">
                <h1><a name="Storage">Storage</a></h1>

<blockquote>
  <p>Provides access to the devices storage options.</p>
</blockquote>

<p>This API is based on the <a class="external" href="http://dev.w3.org/html5/webdatabase/">W3C Web SQL </a><a href="cordova_storage_storage.md.html#Database">Database</a> Specification and <a class="external" href="http://dev.w3.org/html5/webstorage/">W3C Web </a><a href="cordova_storage_storage.md.html#Storage">Storage</a> API Specification. Some devices already provide an implementation of this spec. For those devices, the built-in support is used instead of replacing it with Cordova's implementation. For devices that don't have storage support, Cordova's implementation should be compatible with the W3C specification.</p>

<h2>
<a name="Storage_methods">Methods</a>
</h2>

<ul>
<li><a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a></li>
</ul>
<h2>
<a name="Storage_arguments">Arguments</a>
</h2>

<ul>
<li><a href="cordova_storage_storage.md.html#database_name">database_name</a></li>
<li><a href="cordova_storage_storage.md.html#database_version">database_version</a></li>
<li><a href="cordova_storage_storage.md.html#database_displayname">database_displayname</a></li>
<li><a href="cordova_storage_storage.md.html#database_size">database_size</a></li>
</ul>
<h2>
<a name="Storage_objects">Objects</a>
</h2>

<ul>
<li><a href="cordova_storage_storage.md.html#Database">Database</a></li>
<li><a href="cordova_storage_storage.md.html#SQLTransaction">SQLTransaction</a></li>
<li><a href="cordova_storage_storage.md.html#SQLResultSet">SQLResultSet</a></li>
<li><a href="cordova_storage_storage.md.html#SQLResultSetList">SQLResultSetList</a></li>
<li><a href="cordova_storage_storage.md.html#SQLError">SQLError</a></li>
<li><a href="cordova_storage_storage.md.html#localStorage">localStorage</a></li>
</ul>
<h2>
<a name="Storage_permissions">Permissions</a>
</h2>

<h3>Android</h3>

<h4>app/res/xml/config.xml</h4>

<pre class="prettyprint"><code>&lt;plugin name="<a href="cordova_storage_storage.md.html#Storage">Storage</a>" value="org.apache.cordova.<a href="cordova_storage_storage.md.html#Storage">Storage</a>" /&gt;
</code></pre>

<h3>Bada</h3>

<pre class="prettyprint"><code>No permissions are required.
</code></pre>

<h3>BlackBerry WebWorks</h3>

<h4>www/config.xml</h4>

<pre class="prettyprint"><code>&lt;feature id="blackberry.widgetcache" required="true" version="1.0.0.0" /&gt;
</code></pre>

<h3>iOS</h3>

<pre class="prettyprint"><code>No permissions are required.
</code></pre>

<h3>webOS</h3>

<pre class="prettyprint"><code>No permissions are required.
</code></pre>

<h3>Windows Phone</h3>

<pre class="prettyprint"><code>No permissions are required.
</code></pre>

<h3>Tizen</h3>

<pre class="prettyprint"><code>No permissions are required.
</code></pre>

<hr>
<h1><a name="openDatabase">openDatabase</a></h1>

<p>Returns a new <a href="cordova_storage_storage.md.html#Database">Database</a> object.</p>

<pre class="prettyprint"><code>var dbShell = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>(<a href="cordova_storage_storage.md.html#database_name">database_name</a>, <a href="cordova_storage_storage.md.html#database_version">database_version</a>, <a href="cordova_storage_storage.md.html#database_displayname">database_displayname</a>, <a href="cordova_storage_storage.md.html#database_size">database_size</a>);
</code></pre>

<h2>
<a name="openDatabase_description">Description</a>
</h2>

<p>window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a> returns a new <a href="cordova_storage_storage.md.html#Database">Database</a> object.</p>

<p>This method will create a new SQL Lite <a href="cordova_storage_storage.md.html#Database">Database</a> and return a <a href="cordova_storage_storage.md.html#Database">Database</a> object.  Use the <a href="cordova_storage_storage.md.html#Database">Database</a> Object to manipulate the data.</p>

<h2>
<a name="openDatabase_supported_platforms">Supported Platforms</a>
</h2>

<ul>
<li>Android</li>
<li>BlackBerry WebWorks (OS 6.0 and higher)</li>
<li>iPhone</li>
<li>webOS</li>
<li>Tizen</li>
</ul>
<h2>
<a name="openDatabase_quick_example">Quick Example</a>
</h2>

<pre class="prettyprint"><code>var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("test", "1.0", "Test DB", 1000000);
</code></pre>

<h2>
<a name="openDatabase_full_example">Full Example</a>
</h2>

<pre class="prettyprint"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;<a href="cordova_storage_storage.md.html#Storage">Storage</a> Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for Cordova to load
    //
    document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("test", "1.0", "Test DB", 1000000);
    }

    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;Example&lt;/h1&gt;
    &lt;p&gt;Open <a href="cordova_storage_storage.md.html#Database">Database</a>&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<hr>
<h1><a name="database_name">database_name</a></h1>

<p>The name of the database.</p>

<hr>
<h1><a name="database_version">database_version</a></h1>

<p>The version of the database.</p>

<hr>
<h1><a name="database_displayname">database_displayname</a></h1>

<p>The display name of the database.</p>

<hr>
<h1><a name="database_size">database_size</a></h1>

<p>The size of the database in bytes.</p>

<hr>
<h1><a name="Database">Database</a></h1>

<p>Contains methods that allow the user to manipulate the <a href="cordova_storage_storage.md.html#Database">Database</a></p>

<h2>
<a name="Database_methods">Methods</a>
</h2>

<ul>
<li>
<strong>transaction</strong>: Runs a database transaction. </li>
<li>
<strong>changeVersion</strong>: method allows scripts to atomically verify the version number and change it at the same time as doing a schema update. </li>
</ul>
<h2>
<a name="Database_details">Details</a>
</h2>

<p>A <a href="cordova_storage_storage.md.html#Database">Database</a> object is returned from a call to <code>window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>()</code>.</p>

<h2>
<a name="Database_supported_platforms">Supported Platforms</a>
</h2>

<ul>
<li>Android</li>
<li>BlackBerry WebWorks (OS 6.0 and higher)</li>
<li>iPhone</li>
<li>webOS</li>
<li>Tizen</li>
</ul>
<h2>
<a name="Database_transaction_quick_example">Transaction Quick Example</a>
</h2>

<pre class="prettyprint"><code>function populateDB(tx) {
     tx.executeSql('DROP TABLE IF EXISTS DEMO');
     tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
     tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
     tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
}

function errorCB(err) {
    alert("Error processing SQL: "+err.code);
}

function successCB() {
    alert("success!");
}

var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("<a href="cordova_storage_storage.md.html#Database">Database</a>", "1.0", "Cordova Demo", 200000);
db.transaction(populateDB, errorCB, successCB);
</code></pre>

<h2>
<a name="Database_change_version_quick_example">Change Version Quick Example</a>
</h2>

<pre class="prettyprint"><code>var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("<a href="cordova_storage_storage.md.html#Database">Database</a>", "1.0", "Cordova Demo", 200000);
db.changeVersion("1.0", "1.1");
</code></pre>

<h2>
<a name="Database_full_example">Full Example</a>
</h2>

<pre class="prettyprint"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;<a href="cordova_storage_storage.md.html#Storage">Storage</a> Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for Cordova to load
    //
    document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("<a href="cordova_storage_storage.md.html#Database">Database</a>", "1.0", "Cordova Demo", 200000);
        db.transaction(populateDB, errorCB, successCB);
    }

    // Populate the database 
    //
    function populateDB(tx) {
         tx.executeSql('DROP TABLE IF EXISTS DEMO');
         tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
         tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
         tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
    }

    // Transaction error callback
    //
    function errorCB(tx, err) {
        alert("Error processing SQL: "+err);
    }

    // Transaction success callback
    //
    function successCB() {
        alert("success!");
    }

    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;Example&lt;/h1&gt;
    &lt;p&gt;<a href="cordova_storage_storage.md.html#Database">Database</a>&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<hr>
<h1><a name="SQLTransaction">SQLTransaction</a></h1>

<p>Contains methods that allow the user to execute SQL statements against the <a href="cordova_storage_storage.md.html#Database">Database</a>.</p>

<h2>
<a name="SQLTransaction_methods">Methods</a>
</h2>

<ul>
<li>
<strong>executeSql</strong>: executes a SQL statement</li>
</ul>
<h2>
<a name="SQLTransaction_details">Details</a>
</h2>

<p>When you call a <a href="cordova_storage_storage.md.html#Database">Database</a> objects transaction method it's callback methods will be called with a <a href="cordova_storage_storage.md.html#SQLTransaction">SQLTransaction</a> object.  The user can build up a database transaction by calling the executeSql method multiple times.  </p>

<h2>
<a name="SQLTransaction_supported_platforms">Supported Platforms</a>
</h2>

<ul>
<li>Android</li>
<li>BlackBerry WebWorks (OS 6.0 and higher)</li>
<li>iPhone</li>
<li>webOS</li>
<li>Tizen</li>
</ul>
<h2>
<a name="SQLTransaction_execute_sql_quick_example">Execute SQL Quick Example</a>
</h2>

<pre class="prettyprint"><code>function populateDB(tx) {
     tx.executeSql('DROP TABLE IF EXISTS DEMO');
     tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
     tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
     tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
}

function errorCB(err) {
    alert("Error processing SQL: "+err);
}

function successCB() {
    alert("success!");
}

var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("<a href="cordova_storage_storage.md.html#Database">Database</a>", "1.0", "Cordova Demo", 200000);
db.transaction(populateDB, errorCB, successCB);
</code></pre>

<h2>
<a name="SQLTransaction_full_example">Full Example</a>
</h2>

<pre class="prettyprint"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;<a href="cordova_storage_storage.md.html#Storage">Storage</a> Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for Cordova to load
    //
    document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("<a href="cordova_storage_storage.md.html#Database">Database</a>", "1.0", "Cordova Demo", 200000);
        db.transaction(populateDB, errorCB, successCB);
    }

    // Populate the database 
    //
    function populateDB(tx) {
         tx.executeSql('DROP TABLE IF EXISTS DEMO');
         tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
         tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
         tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
    }

    // Transaction error callback
    //
    function errorCB(err) {
        alert("Error processing SQL: "+err);
    }

    // Transaction success callback
    //
    function successCB() {
        alert("success!");
    }

    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;Example&lt;/h1&gt;
    &lt;p&gt;<a href="cordova_storage_storage.md.html#SQLTransaction">SQLTransaction</a>&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<hr>
<h1><a name="SQLResultSet">SQLResultSet</a></h1>

<p>When the executeSql method of a <a href="cordova_storage_storage.md.html#SQLTransaction">SQLTransaction</a> is called it will invoke it's callback with a <a href="cordova_storage_storage.md.html#SQLResultSet">SQLResultSet</a>.</p>

<h2>
<a name="SQLResultSet_properties">Properties</a>
</h2>

<ul>
<li>
<strong>insertId</strong>: the row ID of the row that the <a href="cordova_storage_storage.md.html#SQLResultSet">SQLResultSet</a> object's SQL statement inserted into the database</li>
<li>
<strong>rowsAffected</strong>: the number of rows that were changed by the SQL statement.  If the statement did not affect any rows then it is set to 0. </li>
<li>
<strong>rows</strong>: a SQLResultSetRowList representing the rows returned.  If no rows are returned the object will be empty.</li>
</ul>
<h2>
<a name="SQLResultSet_details">Details</a>
</h2>

<p>When you call the <a href="cordova_storage_storage.md.html#SQLTransaction">SQLTransaction</a> executeSql method its callback methods will be called with a <a href="cordova_storage_storage.md.html#SQLResultSet">SQLResultSet</a> object.  The result object has three properties.  The first is the <code>insertId</code> which will return the row number of a success SQL insert statement.  If the SQL statement is not an insert then the <code>insertId</code> is not set.  The <code>rowsAffected</code> is always 0 for a SQL select statement.  For insert or update statements it returns the number of rows that have been modified.  The final property is of type <a href="cordova_storage_storage.md.html#SQLResultSetList">SQLResultSetList</a> and it contains the data returned from a SQL select statement.</p>

<h2>
<a name="SQLResultSet_supported_platforms">Supported Platforms</a>
</h2>

<ul>
<li>Android</li>
<li>BlackBerry WebWorks (OS 6.0 and higher)</li>
<li>iPhone</li>
<li>webOS</li>
<li>Tizen</li>
</ul>
<h2>
<a name="SQLResultSet_execute_sql_quick_example">Execute SQL Quick Example</a>
</h2>

<pre class="prettyprint"><code>function queryDB(tx) {
    tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
}

function querySuccess(tx, results) {
console.log("Returned rows = " + results.rows.length);
// this will be true since it was a select statement and so rowsAffected was 0
if (!resultSet.rowsAffected) {
  console.log('No rows affected!');
  return false;
}
// for an insert statement, this property will return the ID of the last inserted row
console.log("Last inserted row ID = " + results.insertId);
}

function errorCB(err) {
    alert("Error processing SQL: "+err.code);
}

var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("<a href="cordova_storage_storage.md.html#Database">Database</a>", "1.0", "Cordova Demo", 200000);
db.transaction(queryDB, errorCB);
</code></pre>

<h2>
<a name="SQLResultSet_full_example">Full Example</a>
</h2>

<pre class="prettyprint"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;<a href="cordova_storage_storage.md.html#Storage">Storage</a> Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for Cordova to load
    //
    document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);

    // Populate the database 
    //
    function populateDB(tx) {
        tx.executeSql('DROP TABLE IF EXISTS DEMO');
        tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
        tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
        tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
    }

    // Query the database
    //
    function queryDB(tx) {
        tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
    }

    // Query the success callback
    //
    function querySuccess(tx, results) {
  console.log("Returned rows = " + results.rows.length);
  // this will be true since it was a select statement and so rowsAffected was 0
  if (!results.rowsAffected) {
    console.log('No rows affected!');
    return false;
  }
  // for an insert statement, this property will return the ID of the last inserted row
  console.log("Last inserted row ID = " + results.insertId);
    }

    // Transaction error callback
    //
    function errorCB(err) {
        console.log("Error processing SQL: "+err.code);
    }

    // Transaction success callback
    //
    function successCB() {
        var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("<a href="cordova_storage_storage.md.html#Database">Database</a>", "1.0", "Cordova Demo", 200000);
        db.transaction(queryDB, errorCB);
    }

    // Cordova is ready
    //
    function onDeviceReady() {
        var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("<a href="cordova_storage_storage.md.html#Database">Database</a>", "1.0", "Cordova Demo", 200000);
        db.transaction(populateDB, errorCB, successCB);
    }

    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;Example&lt;/h1&gt;
    &lt;p&gt;<a href="cordova_storage_storage.md.html#Database">Database</a>&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<hr>
<h1><a name="SQLResultSetList">SQLResultSetList</a></h1>

<p>One of the properties of the <a href="cordova_storage_storage.md.html#SQLResultSet">SQLResultSet</a> containing the rows returned from a SQL query.</p>

<h2>
<a name="SQLResultSetList_properties">Properties</a>
</h2>

<ul>
<li>
<strong>length</strong>: the number of rows returned by the SQL query</li>
</ul>
<h2>
<a name="SQLResultSetList_methods">Methods</a>
</h2>

<ul>
<li>
<strong>item</strong>: returns the row at the specified index represented by a JavaScript object.</li>
</ul>
<h2>
<a name="SQLResultSetList_details">Details</a>
</h2>

<p>The <a href="cordova_storage_storage.md.html#SQLResultSetList">SQLResultSetList</a> contains the data returned from a SQL select statement.  The object contains a length property letting you know how many rows the select statement has been returned.  To get a row of data you would call the <code>item</code> method specifing an index.  The item method returns a JavaScript Object who's properties are the columns of the database the select statement was executed against.</p>

<h2>
<a name="SQLResultSetList_supported_platforms">Supported Platforms</a>
</h2>

<ul>
<li>Android</li>
<li>BlackBerry WebWorks (OS 6.0 and higher)</li>
<li>iPhone</li>
<li>webOS</li>
<li>Tizen</li>
</ul>
<h2>
<a name="SQLResultSetList_execute_sql_quick_example">Execute SQL Quick Example</a>
</h2>

<pre class="prettyprint"><code>function queryDB(tx) {
    tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
}

function querySuccess(tx, results) {
    var len = results.rows.length;
    console.log("DEMO table: " + len + " rows found.");
    for (var i=0; i&lt;len; i++){
        console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data =  " + results.rows.item(i).data);
    }
}

function errorCB(err) {
    alert("Error processing SQL: "+err.code);
}

var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("<a href="cordova_storage_storage.md.html#Database">Database</a>", "1.0", "Cordova Demo", 200000);
db.transaction(queryDB, errorCB);
</code></pre>

<h2>
<a name="SQLResultSetList_full_example">Full Example</a>
</h2>

<pre class="prettyprint"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;<a href="cordova_storage_storage.md.html#Storage">Storage</a> Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for Cordova to load
    //
    document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);

    // Populate the database 
    //
    function populateDB(tx) {
        tx.executeSql('DROP TABLE IF EXISTS DEMO');
        tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
        tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
        tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
    }

    // Query the database
    //
    function queryDB(tx) {
        tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
    }

    // Query the success callback
    //
    function querySuccess(tx, results) {
        var len = results.rows.length;
        console.log("DEMO table: " + len + " rows found.");
        for (var i=0; i&lt;len; i++){
            console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data =  " + results.rows.item(i).data);
        }
    }

    // Transaction error callback
    //
    function errorCB(err) {
        console.log("Error processing SQL: "+err.code);
    }

    // Transaction success callback
    //
    function successCB() {
        var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("<a href="cordova_storage_storage.md.html#Database">Database</a>", "1.0", "Cordova Demo", 200000);
        db.transaction(queryDB, errorCB);
    }

    // Cordova is ready
    //
    function onDeviceReady() {
        var db = window.<a href="cordova_storage_storage.md.html#openDatabase">openDatabase</a>("<a href="cordova_storage_storage.md.html#Database">Database</a>", "1.0", "Cordova Demo", 200000);
        db.transaction(populateDB, errorCB, successCB);
    }

    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;Example&lt;/h1&gt;
    &lt;p&gt;<a href="cordova_storage_storage.md.html#Database">Database</a>&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<hr>
<h1><a name="SQLError">SQLError</a></h1>

<p>A <code><a href="cordova_storage_storage.md.html#SQLError">SQLError</a></code> object is thrown when an error occurs.</p>

<h2>
<a name="SQLError_properties">Properties</a>
</h2>

<ul>
<li>
<strong>code:</strong> One of the predefined error codes listed below.</li>
<li>
<strong>message:</strong> A description of the error.</li>
</ul>
<h2>
<a name="SQLError_constants">Constants</a>
</h2>

<ul>
<li><code><a href="cordova_storage_storage.md.html#SQLError">SQLError</a>.UNKNOWN_ERR</code></li>
<li><code><a href="cordova_storage_storage.md.html#SQLError">SQLError</a>.DATABASE_ERR</code></li>
<li><code><a href="cordova_storage_storage.md.html#SQLError">SQLError</a>.VERSION_ERR</code></li>
<li><code><a href="cordova_storage_storage.md.html#SQLError">SQLError</a>.TOO_LARGE_ERR</code></li>
<li><code><a href="cordova_storage_storage.md.html#SQLError">SQLError</a>.QUOTA_ERR</code></li>
<li><code><a href="cordova_storage_storage.md.html#SQLError">SQLError</a>.SYNTAX_ERR</code></li>
<li><code><a href="cordova_storage_storage.md.html#SQLError">SQLError</a>.CONSTRAINT_ERR</code></li>
<li><code><a href="cordova_storage_storage.md.html#SQLError">SQLError</a>.TIMEOUT_ERR</code></li>
</ul>
<h2>
<a name="SQLError_description">Description</a>
</h2>

<p>The <code><a href="cordova_storage_storage.md.html#SQLError">SQLError</a></code> object is thrown when an error occurs when manipulating a database.</p>

<hr>
<h1><a name="localStorage">localStorage</a></h1>

<p>Provides access to a W3C <a href="cordova_storage_storage.md.html#Storage">Storage</a> interface (http://dev.w3.org/html5/webstorage/#the-localstorage-attribute)</p>

<pre class="prettyprint"><code>var storage = window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>;
</code></pre>

<h2>
<a name="localStorage_methods">Methods</a>
</h2>

<ul>
<li>
<strong>key</strong>: Returns the name of the key at the position specified. </li>
<li>
<strong>getItem</strong>: Returns the item identified by it's key.</li>
<li>
<strong>setItem</strong>: Saves and item at the key provided.</li>
<li>
<strong>removeItem</strong>: Removes the item identified by it's key.</li>
<li>
<strong>clear</strong>: Removes all of the key value pairs.</li>
</ul>
<h2>
<a name="localStorage_details">Details</a>
</h2>

<p><a href="cordova_storage_storage.md.html#localStorage">localStorage</a> provides an interface to a W3C <a href="cordova_storage_storage.md.html#Storage">Storage</a> interface.  It allows one to save data as key-value pairs.</p>

<p>Note: window.sessionStorage provides the same interface, but is cleared between app launches.</p>

<h2>
<a name="localStorage_supported_platforms">Supported Platforms</a>
</h2>

<ul>
<li>Android</li>
<li>BlackBerry WebWorks (OS 6.0 and higher)</li>
<li>iPhone</li>
<li>Windows Phone 7</li>
<li>webOS</li>
<li>Tizen</li>
</ul>
<h2>
<a name="localStorage_key_quick_example">Key Quick Example</a>
</h2>

<pre class="prettyprint"><code>var keyName = window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.key(0);
</code></pre>

<h2>
<a name="localStorage_set_item_quick_example">Set Item Quick Example</a>
</h2>

<pre class="prettyprint"><code>window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.setItem("key", "value");
</code></pre>

<h2>
<a name="localStorage_get_item_quick_example">Get Item Quick Example</a>
</h2>

<pre class="prettyprint"><code>var value = window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.getItem("key");
// value is now equal to "value"
</code></pre>

<h2>
<a name="localStorage_remove_item_quick_example">Remove Item Quick Example</a>
</h2>

<pre class="prettyprint"><code>window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.removeItem("key");
</code></pre>

<h2>
<a name="localStorage_clear_quick_example">Clear Quick Example</a>
</h2>

<pre class="prettyprint"><code>window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.clear();
</code></pre>

<h2>
<a name="localStorage_full_example">Full Example</a>
</h2>

<pre class="prettyprint"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;<a href="cordova_storage_storage.md.html#Storage">Storage</a> Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for Cordova to load
    //
    document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.setItem("key", "value");
        var keyname = window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.key(i);
        // keyname is now equal to "key"
        var value = window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.getItem("key");
        // value is now equal to "value"
        window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.removeItem("key");
        window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.setItem("key2", "value2");
        window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.clear();
        // <a href="cordova_storage_storage.md.html#localStorage">localStorage</a> is now empty
    }


    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;Example&lt;/h1&gt;
    &lt;p&gt;<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<h2>
<a name="localStorage_windows_phone_7_quirks">Windows Phone 7 Quirks</a>
</h2>

<ul>
<li>dot notation is NOT available on Windows Phone. Be sure to use : window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.setItem/getItem, and not the w3 spec defined calls to window.<a href="cordova_storage_storage.md.html#localStorage">localStorage</a>.someKey = 'someValue';</li>
</ul>
</div>
        </div>

        <!-- Functionality and Syntax Highlighting -->
        <script type="text/javascript" src="index.js"></script><script type="text/javascript" src="prettify/prettify.js"></script>
</body>
</html>
